import React from 'react'

class ConditionDemo extends React.Component {
    constructor(props) {
        super(props)
        this.state = { theme: 'black' }
    }
    render() {
        const blackText = <p style={{color: 'black'}}>Black Text</p>
        const blueText = <p style={{color: 'blue'}}>Blue Text</p>

        return <div>
            <h3>条件</h3>
            { this.state.theme === 'black' ? blackText : '' }
            { this.state.theme === 'blue' && blueText }
        </div>

        // if (this.state.theme === 'black') {
        //     return blackText
        // } else {
        //     return blueText
        // }
    }
}

export default ConditionDemo